<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:form id="frmTitle">
        <p:growl id="msgs" showDetail="false"/>
        <h:panelGrid columns="2" cellpadding="1">
            <h:outputText value="Lista de solicitações abertas" styleClass="fontTitle"/>
        </h:panelGrid>
    </h:form>

    <h:panelGrid columns="2" width="100%">

        <h:form id="frmSearch">

            <h:panelGrid columns="3">

                <p:commandLink id="refreshTable" actionListener="#{funcionarioSolicitacaoMB.atualizarTabela}" title="#{msgs.btnAtualizar}"  update=":frmDataTable:tbl" >
                    <h:graphicImage value="img/refresh.png" style="border: 0" />
                </p:commandLink>

                <p:inputText id="txtBusca" value="#{funcionarioSolicitacaoMB.busca}" size="35" />
                <p:commandButton id="btnSearch" value="#{msgs.btnBuscar}" alt="#{msgs.btnBuscar}" title="#{msgs.btnBuscar}" actionListener="#{funcionarioSolicitacaoMB.buscar}" icon="ui-icon ui-icon-search" update=":frmDataTable:tbl"/>

            </h:panelGrid>

        </h:form>

    </h:panelGrid>

    <h:form id="frmDataTable">

        <p:fieldset legend="solicitações">

            <h:panelGrid width="100%">            

                <p:dataTable id="tbl" var="tbl" paginator="true" paginatorPosition="bottom" rowsPerPageTemplate="5,10,15" rows="10"
                             emptyMessage="#{msgs.msgTabelaVazia}" value="#{funcionarioSolicitacaoMB.lssolicitacao}">
                    <f:facet name="header">
                        <h:outputText value="#{msgs.solicitacaoTblTitulo}"/>                    
                    </f:facet>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.descricao}"/>
                        </f:facet>
                        <h:outputText value="#{tbl.modeloSolicitacao.descricao}"/>
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.aluno}"/>
                        </f:facet>
                        <h:outputText value="#{tbl.aluno.nome}"/>
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.colDtCriacao}"/>
                        </f:facet>
                        <h:outputText value="#{tbl.dtcriacao}">
                            <f:convertDateTime pattern="dd/MM/yyyy"/>
                        </h:outputText>
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Departamento atual"/>
                        </f:facet>
                        <h:outputText value="#{tbl.etapaatual.departamento.descricao}"/>
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.colFuncionario}"/>
                        </f:facet>
                         <h:outputText value="#{tbl.funcionario.nome}"/>
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Prazo"/>
                        </f:facet>
                        <h:outputText value="#{funcionarioSolicitacaoMB.calculaData(tbl.dtcriacao,tbl)}">
                            <f:convertDateTime pattern="dd/MM/yyyy"/>
                        </h:outputText>
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.status}"/>
                        </f:facet>
                        <h:outputText value="#{funcionarioSolicitacaoMB.strStatusLabel(tbl.status)}"/>
                    </p:column>

                    <p:column>
                        <p:commandButton id="btnVisualizar" alt="#{msgs.btnVisualizar}" title="#{msgs.btnVisualizar}" icon="ui-icon ui-icon-search" oncomplete="dlgVisualizar.show()" actionListener="#{funcionarioSolicitacaoMB.visualizar(tbl)}" update=":frmVisualizar" />
                        <p:commandButton id="btnCancelar" alt="#{msgs.btnCancelar}" title="#{msgs.btnCancelar}" icon="ui-icon ui-icon-close" oncomplete="cfmDlgCancelar.show()" actionListener="#{funcionarioSolicitacaoMB.selecionarRegistro(tbl)}" update=":frmCancelar" rendered="false"/>
                        <p:commandButton id="btnAssumirSolicitacao" alt="#{msgs.btnAssumir}" title="#{msgs.btnAssumir}" icon="ui-icon ui-icon-person" oncomplete="cfmDlgAssumir.show()" actionListener="#{funcionarioSolicitacaoMB.selecionarRegistro(tbl)}" update=":frmAssumirSolicitacao" rendered="#{tbl.funcionario == null}"/>
                    </p:column>

                </p:dataTable>

            </h:panelGrid>

        </p:fieldset>

    </h:form>
        
    <h:form id="frmVisualizar">
        
        <p:dialog header="#{msgs.visualizar}" widgetVar="dlgVisualizar" width="750"  resizable="false" modal="true" styleClass="styleDialog">
           
            <p:tabView id="idTab">

                <p:tab title="#{msgs.solicitacaoDlgLgdVisualizar}">  
            
                
                    <h:panelGrid columns="2">
                    
                    <h:outputLabel value="#{msgs.descricao}: "/>
                    <h:outputText value="#{funcionarioSolicitacaoMB.strdescricao}"/>
                    
                     <h:outputLabel value="#{msgs.solicitante}: "/>
                    <h:outputText value="#{funcionarioSolicitacaoMB.straluno}"/>
                        
                    <h:outputLabel value="#{msgs.dtcriacao}: "/>
                    <h:outputText value="#{funcionarioSolicitacaoMB.strdtcriacao}">
                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                    </h:outputText>

                    <h:outputLabel value="#{msgs.funcionario}: "/>
                    <h:outputText value="#{funcionarioSolicitacaoMB.strfuncionario}"/>
                   
                    <h:outputLabel value="#{msgs.etapaAtual}: "/>
                    <h:outputText value="#{funcionarioSolicitacaoMB.stretapaatual}"/>
                    
                    <h:outputLabel value="#{msgs.departamentoResponsavel}: "/>
                    <h:outputText value="#{funcionarioSolicitacaoMB.strdepartamento}"/>
                        
                    <h:outputLabel value="#{msgs.status}: "/>
                    <h:outputText value="#{funcionarioSolicitacaoMB.stretapaatualstatus}"/>
                        
                    <h:outputLabel value="#{msgs.colDtPrazo}: "/>
                    <h:outputText value="#{funcionarioSolicitacaoMB.strprazo}">
                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                    </h:outputText>
                        
                </h:panelGrid>
                        
                </p:tab>
                
                <p:tab title="Etapas da Solicitacao">

                    <h:panelGrid columns="1" width="100%">

                        <p:dataTable id="tblProcessoAdd" var="tbl" value="#{funcionarioSolicitacaoMB.lsetapa}" rows="5" paginator="true"
                                     emptyMessage="#{msgs.msgTabelaVazia}" paginatorPosition="bottom">  

                            <f:facet name="header">
                                <h:outputText value="#{msgs.etapaTblTitulo}"/>                    
                            </f:facet>

                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{msgs.descricao}"/>
                                </f:facet>
                                <h:outputText value="#{tbl.descricao}"/>
                            </p:column>

                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Departamento responsavel"/>
                                </f:facet>
                                <h:outputText value="#{tbl.departamento.descricao}"/>
                            </p:column>
                            
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{msgs.colDtCriacao}"/>
                                </f:facet>
                                <h:outputText value="#{tbl.dtcriacao}">
                                    <f:convertDateTime pattern="dd/MM/yyyy"/>
                                </h:outputText>
                            </p:column>
                         
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{msgs.status}"/>
                                </f:facet>
                                <h:outputText value="#{tbl.status.descricao}"/>
                            </p:column>
                            
                            <p:column>
                                <f:facet name="header">
                                </f:facet>
                                <p:commandButton id="btnVisualizarProcesso" alt="#{msgs.btnVisualizar}" title="#{msgs.btnVisualizar}" icon="ui-icon ui-icon-search" oncomplete="dlgProcesso.show()" actionListener="#{funcionarioSolicitacaoMB.buscarProcesso(tbl)}" update=":frmProcesso"/>
                            </p:column>

                        </p:dataTable>  

                    </h:panelGrid>

                </p:tab>
            
            </p:tabView>
            
                <p:commandButton style="width:90px;margin-bottom: 10px;margin-top: 10px;" value="#{msgs.btnFechar}" alt="#{msgs.btnFechar}" title="#{msgs.btnFechar}" onclick="dlgVisualizar.hide()" styleClass="centerButton"/>
            
        </p:dialog>
            
    </h:form>
        
    <h:form id="frmCancelar">
         
        <p:confirmDialog id="confirmDialogCancelar" header="#{msgs.solicitacaoDlgTituloCancelar}" message=" #{msgs.dlgMsgCancelar} #{funcionarioSolicitacaoMB.solicitacaoselecionada.modeloSolicitacao.descricao} ?"
                         width="300" height="60" severity="alert" widgetVar="cfmDlgCancelar">
                             
            <p:commandButton value="#{msgs.btnSim}" oncomplete="cfmDlgCancelar.hide()" alt="#{msgs.btnSim}" title="#{msgs.btnSim}" actionListener="#{funcionarioSolicitacaoMB.cancelar}"
                             update=":frmTitle:msgs,:frmDataTable:tbl"/>
            <p:commandButton value="#{msgs.btnNao}" onclick="cfmDlgCancelar.hide()" alt="#{msgs.btnNao}" title="#{msgs.btnNao}" type="button"/>
                
        </p:confirmDialog>
            
    </h:form>
    
    <h:form id="frmAssumirSolicitacao">
         
        <p:confirmDialog id="confirmDialogAssumir" header="#{msgs.solicitacaoDlgTituloAssumir}" message="#{msgs.dlgMsgAssumir} para si mesmo?"
                         width="300" height="60" severity="alert" widgetVar="cfmDlgAssumir">
                             
            <p:commandButton value="#{msgs.btnSim}" oncomplete="cfmDlgAssumir.hide()" alt="#{msgs.btnSim}" title="#{msgs.btnSim}" actionListener="#{funcionarioSolicitacaoMB.assumirSolicitacao}"
                             update=":frmTitle:msgs,:frmDataTable:tbl"/>
            <p:commandButton value="#{msgs.btnNao}" onclick="cfmDlgAssumir.hide()" alt="#{msgs.btnNao}" title="#{msgs.btnNao}" type="button"/>
                
        </p:confirmDialog>
            
    </h:form>
    
    <h:form id="frmProcesso">
         
            <p:dialog header="#{msgs.visualizar}" widgetVar="dlgProcesso" width="750"  resizable="false" modal="true" styleClass="styleDialog">
             
            <h:panelGrid columns="1" width="100%">
                             
                <p:dataTable id="tblProcesso" var="tbl" value="#{funcionarioSolicitacaoMB.lsprocesso}" rows="5" paginator="true"
                    emptyMessage="#{msgs.msgTabelaVazia}" paginatorPosition="bottom">  
                                              
                    <f:facet name="header">
                        <h:outputText value="#{msgs.processoTblTitulo}"/>                    
                    </f:facet>
                                     
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.orientacao}"/>
                        </f:facet>
                        <h:outputText value="#{tbl.orientacao}"/>
                    </p:column>
                        
                    <p:column>
                         <p:commandButton id="btnConcluirProcesso" alt="#{msgs.btnConcluirProcesso}" title="#{msgs.btnConcluirProcesso}" icon="ui-icon ui-icon-circle-check" oncomplete="cfmDlgProxProcesso.show()" rendered="#{funcionarioSolicitacaoMB.validaProcesso(tbl)}" update=":frmProximoProcesso" />
                         <p:commandButton id="btnConcluirProcessoD" alt="Processo ja concluido" title="Processo ja concluido" icon="ui-icon ui-icon-circle-check" disabled="#{!funcionarioSolicitacaoMB.validaProcesso(tbl)}" rendered="#{!funcionarioSolicitacaoMB.validaProcesso(tbl)}"/>
                    </p:column>
                                     
                </p:dataTable>  
                                 
                <h:panelGrid>
                    <p:commandButton id="btnFechar" value="#{msgs.btnFechar}" onclick="dlgProcesso.hide()" style="width:90px;margin-bottom: 20px;" styleClass="centerButton"/>
                </h:panelGrid>
                                 
            </h:panelGrid>
        </p:dialog>

    </h:form>
    
     <h:form id="frmProximoProcesso">
         
        <p:confirmDialog id="confirmDialogProxProcesso" header="#{msgs.solicitacaoDlgTituloProximo}" message=" #{msgs.solicitacaoDlgTituloProximo}?"
                         width="300" height="60" severity="alert" widgetVar="cfmDlgProxProcesso">
                             
            <p:commandButton value="#{msgs.btnSim}" oncomplete="cfmDlgProxProcesso.hide()" alt="#{msgs.btnSim}" title="#{msgs.btnSim}" actionListener="#{funcionarioSolicitacaoMB.proximoProcesso()}"
                             update=":frmTitle:msgs,:frmDataTable:tbl"/>
            <p:commandButton value="#{msgs.btnNao}" onclick="cfmDlgProxProcesso.hide()" alt="#{msgs.btnNao}" title="#{msgs.btnNao}" type="button"/>
                
        </p:confirmDialog>
            
    </h:form>


</html>

